int TreeSize(struct Node* root)
{
    if (root == NULL)
    {
        return 0;
    }
    int sum = 0;
    for (int i = root->numChildren - 1; i >= 0; i--)
    {
        sum += TreeSize(root->children[i]);
    }
    return sum + 1;
}

void get(struct Node* root, int* a, int* i)
{
    if (root == NULL)
        return;
    for (int j = 0; j < root->numChildren; j++)
    {
        get(root->children[j], a, i);
    }
    a[*i] = root->val;
    *i = *i + 1;
}


int* postorder(struct Node* root, int* returnSize) {
    int len = TreeSize(root);
    *returnSize = len;
    int* a = (int*)malloc(sizeof(int) * len);
    int i = 0;
    get(root, a, &i);
    return a;
}